package com.bailiban.aigou.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bailiban.aigou.dao.UserDao;
import com.bailiban.aigou.entity.User;
import com.bailiban.aigou.service.IUserService;
import com.bailiban.aigou.utils.PageModel;

@Service
public class UserServiceImpl implements IUserService {

	@Resource
	private UserDao userDao;
	
	@Transactional
	public User getUserByName(String username) {
		return userDao.getUserByName(username);
	}

	@Override
	@Transactional
	public PageModel<User> getAdminUser(int pageNo, int pageSize) {
		PageModel<User> pageModel = userDao.getAdminUser(pageNo, pageSize);
		int count = userDao.getAdminUserCount();
		pageModel.setTotalRecords(count);
		return pageModel;
	}

	@Override
	@Transactional
	public void save(User user) {
		userDao.save(user);
	}
}
